| | | 1 | | // Copyright (c) 2020-2023 dotBunny Inc. |
| | | 2 | | // dotBunny licenses this file to you under the BSL-1.0 license. |
| | | 3 | | // See the LICENSE file in the project root for more information. |
| | | 4 | | |
| | | 5 | | using System; |
| | | 6 | | using GDX.Collections; |
| | | 7 | | using UnityEngine; |
| | | 8 | | |
| | | 9 | | namespace GDX.Tables |
| | | 10 | | { |
| | | 11 | | |
| | | 12 | | [CreateAssetMenu(menuName = "GDX/Stable Table", fileName = "GDXStableTable")] |
| | | 13 | | [Serializable] |
| | | 14 | | public class StableTable : ScriptableObject, ITable |
| | | 15 | | { |
| | | 16 | | [Serializable] |
| | | 17 | | internal struct ColumnEntry |
| | | 18 | | { |
| | | 19 | | public Serializable.SerializableTypes ColumnType; |
| | | 20 | | public int columnDenseIndex; |
| | | 21 | | } |
| | | 22 | | |
| | | 23 | | [SerializeField] internal ArrayHolder<string>[] allStringColumns; |
| | | 24 | | [SerializeField] internal ArrayHolder<bool>[] allBoolColumns; |
| | | 25 | | [SerializeField] internal ArrayHolder<char>[] allCharColumns; |
| | | 26 | | [SerializeField] internal ArrayHolder<sbyte>[] allSbyteColumns; |
| | | 27 | | [SerializeField] internal ArrayHolder<byte>[] allByteColumns; |
| | | 28 | | [SerializeField] internal ArrayHolder<short>[] allShortColumns; |
| | | 29 | | [SerializeField] internal ArrayHolder<ushort>[] allUshortColumns; |
| | | 30 | | [SerializeField] internal ArrayHolder<int>[] allIntColumns; |
| | | 31 | | [SerializeField] internal ArrayHolder<uint>[] allUintColumns; |
| | | 32 | | [SerializeField] internal ArrayHolder<long>[] allLongColumns; |
| | | 33 | | [SerializeField] internal ArrayHolder<ulong>[] allUlongColumns; |
| | | 34 | | [SerializeField] internal ArrayHolder<float>[] allFloatColumns; |
| | | 35 | | [SerializeField] internal ArrayHolder<double>[] allDoubleColumns; |
| | | 36 | | [SerializeField] internal ArrayHolder<Vector2>[] allVector2Columns; |
| | | 37 | | [SerializeField] internal ArrayHolder<Vector3>[] allVector3Columns; |
| | | 38 | | [SerializeField] internal ArrayHolder<Vector4>[] allVector4Columns; |
| | | 39 | | [SerializeField] internal ArrayHolder<Vector2Int>[] allVector2IntColumns; |
| | | 40 | | [SerializeField] internal ArrayHolder<Vector3Int>[] allVector3IntColumns; |
| | | 41 | | [SerializeField] internal ArrayHolder<Quaternion>[] allQuaternionColumns; |
| | | 42 | | [SerializeField] internal ArrayHolder<Rect>[] allRectColumns; |
| | | 43 | | [SerializeField] internal ArrayHolder<RectInt>[] allRectIntColumns; |
| | | 44 | | [SerializeField] internal ArrayHolder<Color>[] allColorColumns; |
| | | 45 | | [SerializeField] internal ArrayHolder<LayerMask>[] allLayerMaskColumns; |
| | | 46 | | [SerializeField] internal ArrayHolder<Bounds>[] allBoundsColumns; |
| | | 47 | | [SerializeField] internal ArrayHolder<BoundsInt>[] allBoundsIntColumns; |
| | | 48 | | [SerializeField] internal ArrayHolder<Hash128>[] allHash128Columns; |
| | | 49 | | [SerializeField] internal ArrayHolder<Gradient>[] allGradientColumns; |
| | | 50 | | [SerializeField] internal ArrayHolder<AnimationCurve>[] allAnimationCurveColumns; |
| | | 51 | | [SerializeField] internal ArrayHolder<UnityEngine.Object>[] allObjectRefColumns; |
| | 0 | 52 | | [SerializeField] internal ArrayHolder<string>[] allColumnNames = new ArrayHolder<string>[Serializable.Serializab |
| | 0 | 53 | | [SerializeField] internal ArrayHolder<int>[] allColumnOrders = new ArrayHolder<int>[Serializable.SerializableTyp |
| | | 54 | | |
| | | 55 | | |
| | | 56 | | [SerializeField] |
| | | 57 | | internal string[] allRowNames; |
| | | 58 | | |
| | | 59 | | [SerializeField] |
| | | 60 | | internal int rowCount; |
| | | 61 | | |
| | | 62 | | [SerializeField] |
| | | 63 | | internal ColumnEntry[] columnIDToDenseIndexMap; |
| | | 64 | | |
| | | 65 | | // TODO move with other block |
| | 0 | 66 | | [SerializeField] ArrayHolder<int>[] columnDenseIndexToIDMap = new ArrayHolder<int>[Serializable.SerializableType |
| | | 67 | | |
| | | 68 | | [SerializeField] |
| | | 69 | | internal int columnEntriesFreeListHead; |
| | | 70 | | |
| | | 71 | | [SerializeField] |
| | | 72 | | internal int combinedColumnCount; |
| | | 73 | | |
| | | 74 | | [SerializeField] |
| | 0 | 75 | | internal ulong dataVersion = 1; |
| | | 76 | | |
| | | 77 | | |
| | | 78 | | public ulong GetDataVersion() |
| | 0 | 79 | | { |
| | 0 | 80 | | return dataVersion; |
| | 0 | 81 | | } |
| | | 82 | | |
| | | 83 | | /// <inheritdoc /> |
| | | 84 | | public int GetColumnCount() |
| | 0 | 85 | | { |
| | 0 | 86 | | return combinedColumnCount; |
| | 0 | 87 | | } |
| | | 88 | | |
| | | 89 | | /// <inheritdoc /> |
| | | 90 | | public int GetRowCount() |
| | 0 | 91 | | { |
| | 0 | 92 | | return rowCount; |
| | 0 | 93 | | } |
| | | 94 | | |
| | | 95 | | public ITable.ColumnDescription[] GetOrderedColumns() |
| | 0 | 96 | | { |
| | 0 | 97 | | if (combinedColumnCount == 0) return null; |
| | 0 | 98 | | ITable.ColumnDescription[] returnArray = new ITable.ColumnDescription[combinedColumnCount]; |
| | | 99 | | |
| | 0 | 100 | | for (int columnIndex = 0; columnIndex < Serializable.SerializableTypesCount; columnIndex++) |
| | 0 | 101 | | { |
| | | 102 | | |
| | 0 | 103 | | int[] columnOrders = allColumnOrders[columnIndex].TArray; |
| | 0 | 104 | | int columnOrdersLength = columnOrders?.Length ?? 0; |
| | | 105 | | |
| | 0 | 106 | | int[] columnIndices = columnDenseIndexToIDMap[columnIndex].TArray; |
| | 0 | 107 | | string[] columnNames = allColumnNames[columnIndex].TArray; |
| | | 108 | | |
| | 0 | 109 | | for (int i = 0; i < columnOrdersLength; i++) |
| | 0 | 110 | | { |
| | 0 | 111 | | returnArray[columnOrders[i]] = new ITable.ColumnDescription |
| | | 112 | | { |
| | | 113 | | Name = columnNames[i], |
| | | 114 | | Index = columnIndices[i], |
| | | 115 | | Type = (Serializable.SerializableTypes)columnIndex |
| | | 116 | | }; |
| | 0 | 117 | | } |
| | 0 | 118 | | } |
| | 0 | 119 | | return returnArray; |
| | 0 | 120 | | } |
| | | 121 | | |
| | | 122 | | |
| | | 123 | | // END - View Hacks |
| | | 124 | | |
| | | 125 | | // TODO: Way to set column name |
| | | 126 | | |
| | | 127 | | |
| | | 128 | | |
| | | 129 | | public void AddRow(string rowName = null, int insertAt = -1) |
| | 0 | 130 | | { |
| | 0 | 131 | | insertAt = insertAt < 0 ? rowCount : insertAt; |
| | | 132 | | |
| | 0 | 133 | | Array.Resize(ref allRowNames, rowCount + 1); |
| | 0 | 134 | | for (int i = rowCount; i > insertAt; i--) |
| | 0 | 135 | | { |
| | 0 | 136 | | allRowNames[i] = allRowNames[i - 1]; |
| | 0 | 137 | | } |
| | | 138 | | |
| | 0 | 139 | | rowName ??= string.Empty; |
| | 0 | 140 | | allRowNames[insertAt] = rowName; |
| | | 141 | | |
| | 0 | 142 | | InsertRowsOfTypeInternal(ref allStringColumns, insertAt, 1); |
| | 0 | 143 | | InsertRowsOfTypeInternal(ref allBoolColumns, insertAt, 1); |
| | 0 | 144 | | InsertRowsOfTypeInternal(ref allCharColumns, insertAt, 1); |
| | 0 | 145 | | InsertRowsOfTypeInternal(ref allSbyteColumns, insertAt, 1); |
| | 0 | 146 | | InsertRowsOfTypeInternal(ref allByteColumns, insertAt, 1); |
| | 0 | 147 | | InsertRowsOfTypeInternal(ref allShortColumns, insertAt, 1); |
| | 0 | 148 | | InsertRowsOfTypeInternal(ref allUshortColumns, insertAt, 1); |
| | 0 | 149 | | InsertRowsOfTypeInternal(ref allIntColumns, insertAt, 1); |
| | 0 | 150 | | InsertRowsOfTypeInternal(ref allUintColumns, insertAt, 1); |
| | 0 | 151 | | InsertRowsOfTypeInternal(ref allLongColumns, insertAt, 1); |
| | 0 | 152 | | InsertRowsOfTypeInternal(ref allUlongColumns, insertAt, 1); |
| | 0 | 153 | | InsertRowsOfTypeInternal(ref allFloatColumns, insertAt, 1); |
| | 0 | 154 | | InsertRowsOfTypeInternal(ref allDoubleColumns, insertAt, 1); |
| | 0 | 155 | | InsertRowsOfTypeInternal(ref allVector2Columns, insertAt, 1); |
| | 0 | 156 | | InsertRowsOfTypeInternal(ref allVector3Columns, insertAt, 1); |
| | 0 | 157 | | InsertRowsOfTypeInternal(ref allVector4Columns, insertAt, 1); |
| | 0 | 158 | | InsertRowsOfTypeInternal(ref allVector2IntColumns, insertAt, 1); |
| | 0 | 159 | | InsertRowsOfTypeInternal(ref allVector3IntColumns, insertAt, 1); |
| | 0 | 160 | | InsertRowsOfTypeInternal(ref allQuaternionColumns, insertAt, 1); |
| | 0 | 161 | | InsertRowsOfTypeInternal(ref allRectColumns, insertAt, 1); |
| | 0 | 162 | | InsertRowsOfTypeInternal(ref allRectIntColumns, insertAt, 1); |
| | 0 | 163 | | InsertRowsOfTypeInternal(ref allColorColumns, insertAt, 1); |
| | 0 | 164 | | InsertRowsOfTypeInternal(ref allLayerMaskColumns, insertAt, 1); |
| | 0 | 165 | | InsertRowsOfTypeInternal(ref allBoundsColumns, insertAt, 1); |
| | 0 | 166 | | InsertRowsOfTypeInternal(ref allBoundsIntColumns, insertAt, 1); |
| | 0 | 167 | | InsertRowsOfTypeInternal(ref allHash128Columns, insertAt, 1); |
| | 0 | 168 | | InsertRowsOfTypeInternal(ref allGradientColumns, insertAt, 1); |
| | 0 | 169 | | InsertRowsOfTypeInternal(ref allAnimationCurveColumns, insertAt, 1); |
| | 0 | 170 | | InsertRowsOfTypeInternal(ref allObjectRefColumns, insertAt, 1); |
| | | 171 | | |
| | 0 | 172 | | ++rowCount; |
| | 0 | 173 | | dataVersion++; |
| | 0 | 174 | | } |
| | | 175 | | |
| | | 176 | | public void AddRows(int numberOfNewRows, string[] rowNames = null, int insertAt = -1) |
| | 0 | 177 | | { |
| | 0 | 178 | | insertAt = insertAt < 0 ? rowCount : insertAt; |
| | | 179 | | |
| | 0 | 180 | | Array.Resize(ref allRowNames, rowCount + 1); |
| | 0 | 181 | | for (int i = rowCount; i > insertAt; i--) |
| | 0 | 182 | | { |
| | 0 | 183 | | allRowNames[i] = allRowNames[i - 1]; |
| | 0 | 184 | | } |
| | | 185 | | |
| | 0 | 186 | | string empty = string.Empty; |
| | 0 | 187 | | int rowNamesLength = rowNames?.Length ?? 0; |
| | 0 | 188 | | for (int i = 0; i < rowNames.Length; i++) |
| | 0 | 189 | | { |
| | 0 | 190 | | string nameAt = rowNames[i]; |
| | 0 | 191 | | allRowNames[insertAt + i] = nameAt ?? empty; |
| | 0 | 192 | | } |
| | | 193 | | |
| | 0 | 194 | | for (int i = rowNamesLength; i < numberOfNewRows; i++) |
| | 0 | 195 | | { |
| | 0 | 196 | | allRowNames[insertAt + i] = empty; |
| | 0 | 197 | | } |
| | | 198 | | |
| | 0 | 199 | | InsertRowsOfTypeInternal(ref allStringColumns, insertAt, numberOfNewRows); |
| | 0 | 200 | | InsertRowsOfTypeInternal(ref allBoolColumns, insertAt, numberOfNewRows); |
| | 0 | 201 | | InsertRowsOfTypeInternal(ref allCharColumns, insertAt, numberOfNewRows); |
| | 0 | 202 | | InsertRowsOfTypeInternal(ref allSbyteColumns, insertAt, numberOfNewRows); |
| | 0 | 203 | | InsertRowsOfTypeInternal(ref allByteColumns, insertAt, numberOfNewRows); |
| | 0 | 204 | | InsertRowsOfTypeInternal(ref allShortColumns, insertAt, numberOfNewRows); |
| | 0 | 205 | | InsertRowsOfTypeInternal(ref allUshortColumns, insertAt, numberOfNewRows); |
| | 0 | 206 | | InsertRowsOfTypeInternal(ref allIntColumns, insertAt, numberOfNewRows); |
| | 0 | 207 | | InsertRowsOfTypeInternal(ref allUintColumns, insertAt, numberOfNewRows); |
| | 0 | 208 | | InsertRowsOfTypeInternal(ref allLongColumns, insertAt, numberOfNewRows); |
| | 0 | 209 | | InsertRowsOfTypeInternal(ref allUlongColumns, insertAt, numberOfNewRows); |
| | 0 | 210 | | InsertRowsOfTypeInternal(ref allFloatColumns, insertAt, numberOfNewRows); |
| | 0 | 211 | | InsertRowsOfTypeInternal(ref allDoubleColumns, insertAt, numberOfNewRows); |
| | 0 | 212 | | InsertRowsOfTypeInternal(ref allVector2Columns, insertAt, numberOfNewRows); |
| | 0 | 213 | | InsertRowsOfTypeInternal(ref allVector3Columns, insertAt, numberOfNewRows); |
| | 0 | 214 | | InsertRowsOfTypeInternal(ref allVector4Columns, insertAt, numberOfNewRows); |
| | 0 | 215 | | InsertRowsOfTypeInternal(ref allVector2IntColumns, insertAt, numberOfNewRows); |
| | 0 | 216 | | InsertRowsOfTypeInternal(ref allVector3IntColumns, insertAt, numberOfNewRows); |
| | 0 | 217 | | InsertRowsOfTypeInternal(ref allQuaternionColumns, insertAt, numberOfNewRows); |
| | 0 | 218 | | InsertRowsOfTypeInternal(ref allRectColumns, insertAt, numberOfNewRows); |
| | 0 | 219 | | InsertRowsOfTypeInternal(ref allRectIntColumns, insertAt, numberOfNewRows); |
| | 0 | 220 | | InsertRowsOfTypeInternal(ref allColorColumns, insertAt, numberOfNewRows); |
| | 0 | 221 | | InsertRowsOfTypeInternal(ref allLayerMaskColumns, insertAt, numberOfNewRows); |
| | 0 | 222 | | InsertRowsOfTypeInternal(ref allBoundsColumns, insertAt, numberOfNewRows); |
| | 0 | 223 | | InsertRowsOfTypeInternal(ref allBoundsIntColumns, insertAt, numberOfNewRows); |
| | 0 | 224 | | InsertRowsOfTypeInternal(ref allHash128Columns, insertAt, numberOfNewRows); |
| | 0 | 225 | | InsertRowsOfTypeInternal(ref allGradientColumns, insertAt, numberOfNewRows); |
| | 0 | 226 | | InsertRowsOfTypeInternal(ref allAnimationCurveColumns, insertAt, numberOfNewRows); |
| | 0 | 227 | | InsertRowsOfTypeInternal(ref allObjectRefColumns, insertAt, numberOfNewRows); |
| | | 228 | | |
| | 0 | 229 | | rowCount += numberOfNewRows; |
| | 0 | 230 | | dataVersion++; |
| | 0 | 231 | | } |
| | | 232 | | |
| | | 233 | | public void RemoveRow(int removeAt) |
| | 0 | 234 | | { |
| | 0 | 235 | | int newRowCount = rowCount - 1; |
| | 0 | 236 | | for (int j = removeAt; j < newRowCount; j++) |
| | 0 | 237 | | { |
| | 0 | 238 | | allRowNames[j] = allRowNames[j + 1]; |
| | 0 | 239 | | } |
| | | 240 | | |
| | 0 | 241 | | Array.Resize(ref allRowNames, newRowCount); |
| | | 242 | | |
| | 0 | 243 | | DeleteRowsOfTypeInternal(ref allStringColumns, removeAt, 1); |
| | 0 | 244 | | DeleteRowsOfTypeInternal(ref allBoolColumns, removeAt, 1); |
| | 0 | 245 | | DeleteRowsOfTypeInternal(ref allCharColumns, removeAt, 1); |
| | 0 | 246 | | DeleteRowsOfTypeInternal(ref allSbyteColumns, removeAt, 1); |
| | 0 | 247 | | DeleteRowsOfTypeInternal(ref allByteColumns, removeAt, 1); |
| | 0 | 248 | | DeleteRowsOfTypeInternal(ref allShortColumns, removeAt, 1); |
| | 0 | 249 | | DeleteRowsOfTypeInternal(ref allUshortColumns, removeAt, 1); |
| | 0 | 250 | | DeleteRowsOfTypeInternal(ref allIntColumns, removeAt, 1); |
| | 0 | 251 | | DeleteRowsOfTypeInternal(ref allUintColumns, removeAt, 1); |
| | 0 | 252 | | DeleteRowsOfTypeInternal(ref allLongColumns, removeAt, 1); |
| | 0 | 253 | | DeleteRowsOfTypeInternal(ref allUlongColumns, removeAt, 1); |
| | 0 | 254 | | DeleteRowsOfTypeInternal(ref allFloatColumns, removeAt, 1); |
| | 0 | 255 | | DeleteRowsOfTypeInternal(ref allDoubleColumns, removeAt, 1); |
| | 0 | 256 | | DeleteRowsOfTypeInternal(ref allVector2Columns, removeAt, 1); |
| | 0 | 257 | | DeleteRowsOfTypeInternal(ref allVector3Columns, removeAt, 1); |
| | 0 | 258 | | DeleteRowsOfTypeInternal(ref allVector4Columns, removeAt, 1); |
| | 0 | 259 | | DeleteRowsOfTypeInternal(ref allVector2IntColumns, removeAt, 1); |
| | 0 | 260 | | DeleteRowsOfTypeInternal(ref allVector3IntColumns, removeAt, 1); |
| | 0 | 261 | | DeleteRowsOfTypeInternal(ref allQuaternionColumns, removeAt, 1); |
| | 0 | 262 | | DeleteRowsOfTypeInternal(ref allRectColumns, removeAt, 1); |
| | 0 | 263 | | DeleteRowsOfTypeInternal(ref allRectIntColumns, removeAt, 1); |
| | 0 | 264 | | DeleteRowsOfTypeInternal(ref allColorColumns, removeAt, 1); |
| | 0 | 265 | | DeleteRowsOfTypeInternal(ref allLayerMaskColumns, removeAt, 1); |
| | 0 | 266 | | DeleteRowsOfTypeInternal(ref allBoundsColumns, removeAt, 1); |
| | 0 | 267 | | DeleteRowsOfTypeInternal(ref allBoundsIntColumns, removeAt, 1); |
| | 0 | 268 | | DeleteRowsOfTypeInternal(ref allHash128Columns, removeAt, 1); |
| | 0 | 269 | | DeleteRowsOfTypeInternal(ref allGradientColumns, removeAt, 1); |
| | 0 | 270 | | DeleteRowsOfTypeInternal(ref allAnimationCurveColumns, removeAt, 1); |
| | 0 | 271 | | DeleteRowsOfTypeInternal(ref allObjectRefColumns, removeAt, 1); |
| | | 272 | | |
| | 0 | 273 | | --rowCount; |
| | 0 | 274 | | dataVersion++; |
| | 0 | 275 | | } |
| | | 276 | | |
| | | 277 | | public void RemoveRows(int removeAt, int numberOfRowsToDelete) |
| | 0 | 278 | | { |
| | 0 | 279 | | int newRowCount = rowCount - numberOfRowsToDelete; |
| | 0 | 280 | | for (int j = removeAt; j < rowCount - numberOfRowsToDelete; j++) |
| | 0 | 281 | | { |
| | 0 | 282 | | allRowNames[j] = allRowNames[j + numberOfRowsToDelete]; |
| | 0 | 283 | | } |
| | | 284 | | |
| | 0 | 285 | | Array.Resize(ref allRowNames, newRowCount); |
| | | 286 | | |
| | 0 | 287 | | DeleteRowsOfTypeInternal(ref allStringColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 288 | | DeleteRowsOfTypeInternal(ref allBoolColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 289 | | DeleteRowsOfTypeInternal(ref allCharColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 290 | | DeleteRowsOfTypeInternal(ref allSbyteColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 291 | | DeleteRowsOfTypeInternal(ref allByteColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 292 | | DeleteRowsOfTypeInternal(ref allShortColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 293 | | DeleteRowsOfTypeInternal(ref allUshortColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 294 | | DeleteRowsOfTypeInternal(ref allIntColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 295 | | DeleteRowsOfTypeInternal(ref allUintColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 296 | | DeleteRowsOfTypeInternal(ref allLongColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 297 | | DeleteRowsOfTypeInternal(ref allUlongColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 298 | | DeleteRowsOfTypeInternal(ref allFloatColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 299 | | DeleteRowsOfTypeInternal(ref allDoubleColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 300 | | DeleteRowsOfTypeInternal(ref allVector2Columns, removeAt, numberOfRowsToDelete); |
| | 0 | 301 | | DeleteRowsOfTypeInternal(ref allVector3Columns, removeAt, numberOfRowsToDelete); |
| | 0 | 302 | | DeleteRowsOfTypeInternal(ref allVector4Columns, removeAt, numberOfRowsToDelete); |
| | 0 | 303 | | DeleteRowsOfTypeInternal(ref allVector2IntColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 304 | | DeleteRowsOfTypeInternal(ref allVector3IntColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 305 | | DeleteRowsOfTypeInternal(ref allQuaternionColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 306 | | DeleteRowsOfTypeInternal(ref allRectColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 307 | | DeleteRowsOfTypeInternal(ref allRectIntColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 308 | | DeleteRowsOfTypeInternal(ref allColorColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 309 | | DeleteRowsOfTypeInternal(ref allLayerMaskColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 310 | | DeleteRowsOfTypeInternal(ref allBoundsColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 311 | | DeleteRowsOfTypeInternal(ref allBoundsIntColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 312 | | DeleteRowsOfTypeInternal(ref allHash128Columns, removeAt, numberOfRowsToDelete); |
| | 0 | 313 | | DeleteRowsOfTypeInternal(ref allGradientColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 314 | | DeleteRowsOfTypeInternal(ref allAnimationCurveColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 315 | | DeleteRowsOfTypeInternal(ref allObjectRefColumns, removeAt, numberOfRowsToDelete); |
| | | 316 | | |
| | 0 | 317 | | rowCount -= numberOfRowsToDelete; |
| | 0 | 318 | | dataVersion++; |
| | 0 | 319 | | } |
| | | 320 | | |
| | | 321 | | |
| | | 322 | | // TODO: Need to make sure that insertAt is the stableID, also this should return the stableID of the newly crea |
| | | 323 | | public int AddColumn(Serializable.SerializableTypes columnType, string columnName, int insertAt = -1) |
| | 0 | 324 | | { |
| | 0 | 325 | | switch (columnType) |
| | | 326 | | { |
| | | 327 | | case Serializable.SerializableTypes.String: |
| | 0 | 328 | | return AddColumnInternal(columnName, ref allStringColumns, Serializable.SerializableTypes.String, in |
| | | 329 | | case Serializable.SerializableTypes.Char: |
| | 0 | 330 | | return AddColumnInternal(columnName, ref allCharColumns, Serializable.SerializableTypes.Char, insert |
| | | 331 | | case Serializable.SerializableTypes.Bool: |
| | 0 | 332 | | return AddColumnInternal(columnName, ref allBoolColumns, Serializable.SerializableTypes.Bool, insert |
| | | 333 | | case Serializable.SerializableTypes.SByte: |
| | 0 | 334 | | return AddColumnInternal(columnName, ref allSbyteColumns, Serializable.SerializableTypes.SByte, inse |
| | | 335 | | case Serializable.SerializableTypes.Byte: |
| | 0 | 336 | | return AddColumnInternal(columnName, ref allByteColumns, Serializable.SerializableTypes.Byte, insert |
| | | 337 | | case Serializable.SerializableTypes.Short: |
| | 0 | 338 | | return AddColumnInternal(columnName, ref allShortColumns, Serializable.SerializableTypes.Short, inse |
| | | 339 | | case Serializable.SerializableTypes.UShort: |
| | 0 | 340 | | return AddColumnInternal(columnName, ref allUshortColumns, Serializable.SerializableTypes.UShort, in |
| | | 341 | | case Serializable.SerializableTypes.Int: |
| | 0 | 342 | | return AddColumnInternal(columnName, ref allIntColumns, Serializable.SerializableTypes.Int, insertAt |
| | | 343 | | case Serializable.SerializableTypes.UInt: |
| | 0 | 344 | | return AddColumnInternal(columnName, ref allUintColumns, Serializable.SerializableTypes.UInt, insert |
| | | 345 | | case Serializable.SerializableTypes.Long: |
| | 0 | 346 | | return AddColumnInternal(columnName, ref allLongColumns, Serializable.SerializableTypes.Long, insert |
| | | 347 | | case Serializable.SerializableTypes.ULong: |
| | 0 | 348 | | return AddColumnInternal(columnName, ref allUlongColumns, Serializable.SerializableTypes.ULong, inse |
| | | 349 | | case Serializable.SerializableTypes.Float: |
| | 0 | 350 | | return AddColumnInternal(columnName, ref allFloatColumns, Serializable.SerializableTypes.Float, inse |
| | | 351 | | case Serializable.SerializableTypes.Double: |
| | 0 | 352 | | return AddColumnInternal(columnName, ref allDoubleColumns, Serializable.SerializableTypes.Double, in |
| | | 353 | | case Serializable.SerializableTypes.Vector2: |
| | 0 | 354 | | return AddColumnInternal(columnName, ref allVector2Columns, Serializable.SerializableTypes.Vector2, |
| | | 355 | | case Serializable.SerializableTypes.Vector3: |
| | 0 | 356 | | return AddColumnInternal(columnName, ref allVector3Columns, Serializable.SerializableTypes.Vector3, |
| | | 357 | | case Serializable.SerializableTypes.Vector4: |
| | 0 | 358 | | return AddColumnInternal(columnName, ref allVector4Columns, Serializable.SerializableTypes.Vector4, |
| | | 359 | | case Serializable.SerializableTypes.Vector2Int: |
| | 0 | 360 | | return AddColumnInternal(columnName, ref allVector2IntColumns, Serializable.SerializableTypes.Vector |
| | | 361 | | case Serializable.SerializableTypes.Vector3Int: |
| | 0 | 362 | | return AddColumnInternal(columnName, ref allVector3IntColumns, Serializable.SerializableTypes.Vector |
| | | 363 | | case Serializable.SerializableTypes.Quaternion: |
| | 0 | 364 | | return AddColumnInternal(columnName, ref allQuaternionColumns, Serializable.SerializableTypes.Quater |
| | | 365 | | case Serializable.SerializableTypes.Rect: |
| | 0 | 366 | | return AddColumnInternal(columnName, ref allRectColumns, Serializable.SerializableTypes.Rect, insert |
| | | 367 | | case Serializable.SerializableTypes.RectInt: |
| | 0 | 368 | | return AddColumnInternal(columnName, ref allRectIntColumns, Serializable.SerializableTypes.RectInt, |
| | | 369 | | case Serializable.SerializableTypes.Color: |
| | 0 | 370 | | return AddColumnInternal(columnName, ref allColorColumns, Serializable.SerializableTypes.Color, inse |
| | | 371 | | case Serializable.SerializableTypes.LayerMask: |
| | 0 | 372 | | return AddColumnInternal(columnName, ref allLayerMaskColumns, Serializable.SerializableTypes.LayerMa |
| | | 373 | | case Serializable.SerializableTypes.Bounds: |
| | 0 | 374 | | return AddColumnInternal(columnName, ref allBoundsColumns, Serializable.SerializableTypes.Bounds, in |
| | | 375 | | case Serializable.SerializableTypes.BoundsInt: |
| | 0 | 376 | | return AddColumnInternal(columnName, ref allBoundsIntColumns, Serializable.SerializableTypes.BoundsI |
| | | 377 | | case Serializable.SerializableTypes.Hash128: |
| | 0 | 378 | | return AddColumnInternal(columnName, ref allHash128Columns, Serializable.SerializableTypes.Hash128, |
| | | 379 | | case Serializable.SerializableTypes.Gradient: |
| | 0 | 380 | | return AddColumnInternal(columnName, ref allGradientColumns, Serializable.SerializableTypes.Gradient |
| | | 381 | | case Serializable.SerializableTypes.AnimationCurve: |
| | 0 | 382 | | return AddColumnInternal(columnName, ref allAnimationCurveColumns, Serializable.SerializableTypes.An |
| | | 383 | | case Serializable.SerializableTypes.Object: |
| | 0 | 384 | | return AddColumnInternal(columnName, ref allObjectRefColumns, Serializable.SerializableTypes.Object, |
| | | 385 | | } |
| | 0 | 386 | | return -1; |
| | 0 | 387 | | } |
| | | 388 | | |
| | | 389 | | // TODO: need to make sure this is the stable ID? |
| | | 390 | | public void RemoveColumn(Serializable.SerializableTypes columnType, int removeAt = -1) |
| | 0 | 391 | | { |
| | 0 | 392 | | switch (columnType) |
| | | 393 | | { |
| | | 394 | | case Serializable.SerializableTypes.String: |
| | 0 | 395 | | RemoveColumnInternal(ref allStringColumns, Serializable.SerializableTypes.String, removeAt); |
| | 0 | 396 | | break; |
| | | 397 | | case Serializable.SerializableTypes.Char: |
| | 0 | 398 | | RemoveColumnInternal(ref allCharColumns, Serializable.SerializableTypes.Char, removeAt); |
| | 0 | 399 | | break; |
| | | 400 | | case Serializable.SerializableTypes.Bool: |
| | 0 | 401 | | RemoveColumnInternal(ref allBoolColumns, Serializable.SerializableTypes.Bool, removeAt); |
| | 0 | 402 | | break; |
| | | 403 | | case Serializable.SerializableTypes.SByte: |
| | 0 | 404 | | RemoveColumnInternal(ref allSbyteColumns, Serializable.SerializableTypes.SByte, removeAt); |
| | 0 | 405 | | break; |
| | | 406 | | case Serializable.SerializableTypes.Byte: |
| | 0 | 407 | | RemoveColumnInternal(ref allByteColumns, Serializable.SerializableTypes.Byte, removeAt); |
| | 0 | 408 | | break; |
| | | 409 | | case Serializable.SerializableTypes.Short: |
| | 0 | 410 | | RemoveColumnInternal(ref allShortColumns, Serializable.SerializableTypes.Short, removeAt); |
| | 0 | 411 | | break; |
| | | 412 | | case Serializable.SerializableTypes.UShort: |
| | 0 | 413 | | RemoveColumnInternal(ref allUshortColumns, Serializable.SerializableTypes.UShort, removeAt); |
| | 0 | 414 | | break; |
| | | 415 | | case Serializable.SerializableTypes.Int: |
| | 0 | 416 | | RemoveColumnInternal(ref allIntColumns, Serializable.SerializableTypes.Int, removeAt); |
| | 0 | 417 | | break; |
| | | 418 | | case Serializable.SerializableTypes.UInt: |
| | 0 | 419 | | RemoveColumnInternal(ref allUintColumns, Serializable.SerializableTypes.UInt, removeAt); |
| | 0 | 420 | | break; |
| | | 421 | | case Serializable.SerializableTypes.Long: |
| | 0 | 422 | | RemoveColumnInternal(ref allLongColumns, Serializable.SerializableTypes.Long, removeAt); |
| | 0 | 423 | | break; |
| | | 424 | | case Serializable.SerializableTypes.ULong: |
| | 0 | 425 | | RemoveColumnInternal(ref allUlongColumns, Serializable.SerializableTypes.ULong, removeAt); |
| | 0 | 426 | | break; |
| | | 427 | | case Serializable.SerializableTypes.Float: |
| | 0 | 428 | | RemoveColumnInternal(ref allFloatColumns, Serializable.SerializableTypes.Float, removeAt); |
| | 0 | 429 | | break; |
| | | 430 | | case Serializable.SerializableTypes.Double: |
| | 0 | 431 | | RemoveColumnInternal(ref allDoubleColumns, Serializable.SerializableTypes.Double, removeAt); |
| | 0 | 432 | | break; |
| | | 433 | | case Serializable.SerializableTypes.Vector2: |
| | 0 | 434 | | RemoveColumnInternal(ref allVector2Columns, Serializable.SerializableTypes.Vector2, removeAt); |
| | 0 | 435 | | break; |
| | | 436 | | case Serializable.SerializableTypes.Vector3: |
| | 0 | 437 | | RemoveColumnInternal(ref allVector3Columns, Serializable.SerializableTypes.Vector3, removeAt); |
| | 0 | 438 | | break; |
| | | 439 | | case Serializable.SerializableTypes.Vector4: |
| | 0 | 440 | | RemoveColumnInternal(ref allVector4Columns, Serializable.SerializableTypes.Vector4, removeAt); |
| | 0 | 441 | | break; |
| | | 442 | | case Serializable.SerializableTypes.Vector2Int: |
| | 0 | 443 | | RemoveColumnInternal(ref allVector2IntColumns, Serializable.SerializableTypes.Vector2Int, removeAt); |
| | 0 | 444 | | break; |
| | | 445 | | case Serializable.SerializableTypes.Vector3Int: |
| | 0 | 446 | | RemoveColumnInternal(ref allVector3IntColumns, Serializable.SerializableTypes.Vector3Int, removeAt); |
| | 0 | 447 | | break; |
| | | 448 | | case Serializable.SerializableTypes.Quaternion: |
| | 0 | 449 | | RemoveColumnInternal(ref allQuaternionColumns, Serializable.SerializableTypes.Quaternion, removeAt); |
| | 0 | 450 | | break; |
| | | 451 | | case Serializable.SerializableTypes.Rect: |
| | 0 | 452 | | RemoveColumnInternal(ref allRectColumns, Serializable.SerializableTypes.Rect, removeAt); |
| | 0 | 453 | | break; |
| | | 454 | | case Serializable.SerializableTypes.RectInt: |
| | 0 | 455 | | RemoveColumnInternal(ref allRectIntColumns, Serializable.SerializableTypes.RectInt, removeAt); |
| | 0 | 456 | | break; |
| | | 457 | | case Serializable.SerializableTypes.Color: |
| | 0 | 458 | | RemoveColumnInternal(ref allColorColumns, Serializable.SerializableTypes.Color, removeAt); |
| | 0 | 459 | | break; |
| | | 460 | | case Serializable.SerializableTypes.LayerMask: |
| | 0 | 461 | | RemoveColumnInternal(ref allLayerMaskColumns, Serializable.SerializableTypes.LayerMask, removeAt); |
| | 0 | 462 | | break; |
| | | 463 | | case Serializable.SerializableTypes.Bounds: |
| | 0 | 464 | | RemoveColumnInternal(ref allBoundsColumns, Serializable.SerializableTypes.Bounds, removeAt); |
| | 0 | 465 | | break; |
| | | 466 | | case Serializable.SerializableTypes.BoundsInt: |
| | 0 | 467 | | RemoveColumnInternal(ref allBoundsIntColumns, Serializable.SerializableTypes.BoundsInt, removeAt); |
| | 0 | 468 | | break; |
| | | 469 | | case Serializable.SerializableTypes.Hash128: |
| | 0 | 470 | | RemoveColumnInternal(ref allHash128Columns, Serializable.SerializableTypes.Hash128, removeAt); |
| | 0 | 471 | | break; |
| | | 472 | | case Serializable.SerializableTypes.Gradient: |
| | 0 | 473 | | RemoveColumnInternal(ref allGradientColumns, Serializable.SerializableTypes.Gradient, removeAt); |
| | 0 | 474 | | break; |
| | | 475 | | case Serializable.SerializableTypes.AnimationCurve: |
| | 0 | 476 | | RemoveColumnInternal(ref allAnimationCurveColumns, Serializable.SerializableTypes.AnimationCurve, re |
| | 0 | 477 | | break; |
| | | 478 | | case Serializable.SerializableTypes.Object: |
| | 0 | 479 | | RemoveColumnInternal(ref allObjectRefColumns, Serializable.SerializableTypes.Object, removeAt); |
| | 0 | 480 | | break; |
| | | 481 | | } |
| | 0 | 482 | | } |
| | | 483 | | |
| | | 484 | | |
| | | 485 | | |
| | | 486 | | |
| | | 487 | | // Set |
| | | 488 | | |
| | | 489 | | public ulong SetString(int row, int column, string value) |
| | 0 | 490 | | { |
| | 0 | 491 | | return SetCell(row, column, ref allStringColumns, value); |
| | 0 | 492 | | } |
| | | 493 | | |
| | | 494 | | public ulong SetBool(int row, int column, bool value) |
| | 0 | 495 | | { |
| | 0 | 496 | | return SetCell(row, column, ref allBoolColumns, value); |
| | 0 | 497 | | } |
| | | 498 | | |
| | | 499 | | public ulong SetChar(int row, int column, char value) |
| | 0 | 500 | | { |
| | 0 | 501 | | return SetCell(row, column, ref allCharColumns, value); |
| | 0 | 502 | | } |
| | | 503 | | |
| | | 504 | | public ulong SetSByte(int row, int column, sbyte value) |
| | 0 | 505 | | { |
| | 0 | 506 | | return SetCell(row, column, ref allSbyteColumns, value); |
| | 0 | 507 | | } |
| | | 508 | | |
| | | 509 | | public ulong SetByte(int row, int column, byte value) |
| | 0 | 510 | | { |
| | 0 | 511 | | return SetCell(row, column, ref allByteColumns, value); |
| | 0 | 512 | | } |
| | | 513 | | |
| | | 514 | | public ulong SetShort(int row, int column, short value) |
| | 0 | 515 | | { |
| | 0 | 516 | | return SetCell(row, column, ref allShortColumns, value); |
| | 0 | 517 | | } |
| | | 518 | | |
| | | 519 | | public ulong SetUShort(int row, int column, ushort value) |
| | 0 | 520 | | { |
| | 0 | 521 | | return SetCell(row, column, ref allUshortColumns, value); |
| | 0 | 522 | | } |
| | | 523 | | |
| | | 524 | | public ulong SetInt(int row, int column, int value) |
| | 0 | 525 | | { |
| | 0 | 526 | | return SetCell(row, column, ref allIntColumns, value); |
| | 0 | 527 | | } |
| | | 528 | | |
| | | 529 | | public ulong SetUInt(int row, int column, uint value) |
| | 0 | 530 | | { |
| | 0 | 531 | | return SetCell(row, column, ref allUintColumns, value); |
| | 0 | 532 | | } |
| | | 533 | | |
| | | 534 | | public ulong SetLong(int row, int column, long value) |
| | 0 | 535 | | { |
| | 0 | 536 | | return SetCell(row, column, ref allLongColumns, value); |
| | 0 | 537 | | } |
| | | 538 | | |
| | | 539 | | public ulong SetULong(int row, int column, ulong value) |
| | 0 | 540 | | { |
| | 0 | 541 | | return SetCell(row, column, ref allUlongColumns, value); |
| | 0 | 542 | | } |
| | | 543 | | |
| | | 544 | | public ulong SetFloat(int row, int column, float value) |
| | 0 | 545 | | { |
| | 0 | 546 | | return SetCell(row, column, ref allFloatColumns, value); |
| | 0 | 547 | | } |
| | | 548 | | |
| | | 549 | | public ulong SetDouble(int row, int column, double value) |
| | 0 | 550 | | { |
| | 0 | 551 | | return SetCell(row, column, ref allDoubleColumns, value); |
| | 0 | 552 | | } |
| | | 553 | | |
| | | 554 | | public ulong SetVector2(int row, int column, Vector2 value) |
| | 0 | 555 | | { |
| | 0 | 556 | | return SetCell(row, column, ref allVector2Columns, value); |
| | 0 | 557 | | } |
| | | 558 | | |
| | | 559 | | public ulong SetVector3(int row, int column, Vector3 value) |
| | 0 | 560 | | { |
| | 0 | 561 | | return SetCell(row, column, ref allVector3Columns, value); |
| | 0 | 562 | | } |
| | | 563 | | |
| | | 564 | | public ulong SetVector4(int row, int column, Vector4 value) |
| | 0 | 565 | | { |
| | 0 | 566 | | return SetCell(row, column, ref allVector4Columns, value); |
| | 0 | 567 | | } |
| | | 568 | | |
| | | 569 | | public ulong SetVector2Int(int row, int column, Vector2Int value) |
| | 0 | 570 | | { |
| | 0 | 571 | | return SetCell(row, column, ref allVector2IntColumns, value); |
| | 0 | 572 | | } |
| | | 573 | | |
| | | 574 | | public ulong SetVector3Int(int row, int column, Vector3Int value) |
| | 0 | 575 | | { |
| | 0 | 576 | | return SetCell(row, column, ref allVector3IntColumns, value); |
| | 0 | 577 | | } |
| | | 578 | | |
| | | 579 | | public ulong SetQuaternion(int row, int column, Quaternion value) |
| | 0 | 580 | | { |
| | 0 | 581 | | return SetCell(row, column, ref allQuaternionColumns, value); |
| | 0 | 582 | | } |
| | | 583 | | |
| | | 584 | | public ulong SetRect(int row, int column, Rect value) |
| | 0 | 585 | | { |
| | 0 | 586 | | return SetCell(row, column, ref allRectColumns, value); |
| | 0 | 587 | | } |
| | | 588 | | |
| | | 589 | | public ulong SetRectInt(int row, int column, RectInt value) |
| | 0 | 590 | | { |
| | 0 | 591 | | return SetCell(row, column, ref allRectIntColumns, value); |
| | 0 | 592 | | } |
| | | 593 | | |
| | | 594 | | public ulong SetColor(int row, int column, Color value) |
| | 0 | 595 | | { |
| | 0 | 596 | | return SetCell(row, column, ref allColorColumns, value); |
| | 0 | 597 | | } |
| | | 598 | | |
| | | 599 | | public ulong SetLayerMask(int row, int column, LayerMask value) |
| | 0 | 600 | | { |
| | 0 | 601 | | return SetCell(row, column, ref allLayerMaskColumns, value); |
| | 0 | 602 | | } |
| | | 603 | | |
| | | 604 | | public ulong SetBounds(int row, int column, Bounds value) |
| | 0 | 605 | | { |
| | 0 | 606 | | return SetCell(row, column, ref allBoundsColumns, value); |
| | 0 | 607 | | } |
| | | 608 | | |
| | | 609 | | public ulong SetBoundsInt(int row, int column, BoundsInt value) |
| | 0 | 610 | | { |
| | 0 | 611 | | return SetCell(row, column, ref allBoundsIntColumns, value); |
| | 0 | 612 | | } |
| | | 613 | | |
| | | 614 | | public ulong SetHash128(int row, int column, Hash128 value) |
| | 0 | 615 | | { |
| | 0 | 616 | | return SetCell(row, column, ref allHash128Columns, value); |
| | 0 | 617 | | } |
| | | 618 | | |
| | | 619 | | public ulong SetGradient(int row, int column, Gradient value) |
| | 0 | 620 | | { |
| | 0 | 621 | | return SetCell(row, column, ref allGradientColumns, value); |
| | 0 | 622 | | } |
| | | 623 | | |
| | | 624 | | public ulong SetAnimationCurve(int row, int column, AnimationCurve value) |
| | 0 | 625 | | { |
| | 0 | 626 | | return SetCell(row, column, ref allAnimationCurveColumns, value); |
| | 0 | 627 | | } |
| | | 628 | | |
| | | 629 | | public ulong SetObject(int row, int column, UnityEngine.Object value) |
| | 0 | 630 | | { |
| | 0 | 631 | | return SetCell(row, column, ref allObjectRefColumns, value); |
| | 0 | 632 | | } |
| | | 633 | | |
| | | 634 | | // Get |
| | | 635 | | public string GetString(int row, int column) |
| | 0 | 636 | | { |
| | 0 | 637 | | return GetCell(row, column, ref allStringColumns); |
| | 0 | 638 | | } |
| | | 639 | | |
| | | 640 | | public bool GetBool(int row, int column) |
| | 0 | 641 | | { |
| | 0 | 642 | | return GetCell(row, column, ref allBoolColumns); |
| | 0 | 643 | | } |
| | | 644 | | |
| | | 645 | | public char GetChar(int row, int column) |
| | 0 | 646 | | { |
| | 0 | 647 | | return GetCell(row, column, ref allCharColumns); |
| | 0 | 648 | | } |
| | | 649 | | |
| | | 650 | | public sbyte GetSByte(int row, int column) |
| | 0 | 651 | | { |
| | 0 | 652 | | return GetCell(row, column, ref allSbyteColumns); |
| | 0 | 653 | | } |
| | | 654 | | |
| | | 655 | | public byte GetByte(int row, int column) |
| | 0 | 656 | | { |
| | 0 | 657 | | return GetCell(row, column, ref allByteColumns); |
| | 0 | 658 | | } |
| | | 659 | | |
| | | 660 | | public short GetShort(int row, int column) |
| | 0 | 661 | | { |
| | 0 | 662 | | return GetCell(row, column, ref allShortColumns); |
| | 0 | 663 | | } |
| | | 664 | | |
| | | 665 | | public ushort GetUShort(int row, int column) |
| | 0 | 666 | | { |
| | 0 | 667 | | return GetCell(row, column, ref allUshortColumns); |
| | 0 | 668 | | } |
| | | 669 | | |
| | | 670 | | public int GetInt(int row, int column) |
| | 0 | 671 | | { |
| | 0 | 672 | | return GetCell(row, column, ref allIntColumns); |
| | 0 | 673 | | } |
| | | 674 | | |
| | | 675 | | public uint GetUInt(int row, int column) |
| | 0 | 676 | | { |
| | 0 | 677 | | return GetCell(row, column, ref allUintColumns); |
| | 0 | 678 | | } |
| | | 679 | | |
| | | 680 | | public long GetLong(int row, int column) |
| | 0 | 681 | | { |
| | 0 | 682 | | return GetCell(row, column, ref allLongColumns); |
| | 0 | 683 | | } |
| | | 684 | | |
| | | 685 | | public ulong GetULong(int row, int column) |
| | 0 | 686 | | { |
| | 0 | 687 | | return GetCell(row, column, ref allUlongColumns); |
| | 0 | 688 | | } |
| | | 689 | | |
| | | 690 | | public float GetFloat(int row, int column) |
| | 0 | 691 | | { |
| | 0 | 692 | | return GetCell(row, column, ref allFloatColumns); |
| | 0 | 693 | | } |
| | | 694 | | |
| | | 695 | | public double GetDouble(int row, int column) |
| | 0 | 696 | | { |
| | 0 | 697 | | return GetCell(row, column, ref allDoubleColumns); |
| | 0 | 698 | | } |
| | | 699 | | |
| | | 700 | | public Vector2 GetVector2(int row, int column) |
| | 0 | 701 | | { |
| | 0 | 702 | | return GetCell(row, column, ref allVector2Columns); |
| | 0 | 703 | | } |
| | | 704 | | |
| | | 705 | | public Vector3 GetVector3(int row, int column) |
| | 0 | 706 | | { |
| | 0 | 707 | | return GetCell(row, column, ref allVector3Columns); |
| | 0 | 708 | | } |
| | | 709 | | |
| | | 710 | | public Vector4 GetVector4(int row, int column) |
| | 0 | 711 | | { |
| | 0 | 712 | | return GetCell(row, column, ref allVector4Columns); |
| | 0 | 713 | | } |
| | | 714 | | |
| | | 715 | | public Vector2Int GetVector2Int(int row, int column) |
| | 0 | 716 | | { |
| | 0 | 717 | | return GetCell(row, column, ref allVector2IntColumns); |
| | 0 | 718 | | } |
| | | 719 | | |
| | | 720 | | public Vector3Int GetVector3Int(int row, int column) |
| | 0 | 721 | | { |
| | 0 | 722 | | return GetCell(row, column, ref allVector3IntColumns); |
| | 0 | 723 | | } |
| | | 724 | | |
| | | 725 | | public Quaternion GetQuaternion(int row, int column) |
| | 0 | 726 | | { |
| | 0 | 727 | | return GetCell(row, column, ref allQuaternionColumns); |
| | 0 | 728 | | } |
| | | 729 | | |
| | | 730 | | public Rect GetRect(int row, int column) |
| | 0 | 731 | | { |
| | 0 | 732 | | return GetCell(row, column, ref allRectColumns); |
| | 0 | 733 | | } |
| | | 734 | | |
| | | 735 | | public RectInt GetRectInt(int row, int column) |
| | 0 | 736 | | { |
| | 0 | 737 | | return GetCell(row, column, ref allRectIntColumns); |
| | 0 | 738 | | } |
| | | 739 | | |
| | | 740 | | public Color GetColor(int row, int column) |
| | 0 | 741 | | { |
| | 0 | 742 | | return GetCell(row, column, ref allColorColumns); |
| | 0 | 743 | | } |
| | | 744 | | |
| | | 745 | | public LayerMask GetLayerMask(int row, int column) |
| | 0 | 746 | | { |
| | 0 | 747 | | return GetCell(row, column, ref allLayerMaskColumns); |
| | 0 | 748 | | } |
| | | 749 | | |
| | | 750 | | public Bounds GetBounds(int row, int column) |
| | 0 | 751 | | { |
| | 0 | 752 | | return GetCell(row, column, ref allBoundsColumns); |
| | 0 | 753 | | } |
| | | 754 | | |
| | | 755 | | public BoundsInt GetBoundsInt(int row, int column) |
| | 0 | 756 | | { |
| | 0 | 757 | | return GetCell(row, column, ref allBoundsIntColumns); |
| | 0 | 758 | | } |
| | | 759 | | |
| | | 760 | | public Hash128 GetHash128(int row, int column) |
| | 0 | 761 | | { |
| | 0 | 762 | | return GetCell(row, column, ref allHash128Columns); |
| | 0 | 763 | | } |
| | | 764 | | |
| | | 765 | | public Gradient GetGradient(int row, int column) |
| | 0 | 766 | | { |
| | 0 | 767 | | return GetCell(row, column, ref allGradientColumns); |
| | 0 | 768 | | } |
| | | 769 | | |
| | | 770 | | public AnimationCurve GetAnimationCurve(int row, int column) |
| | 0 | 771 | | { |
| | 0 | 772 | | return GetCell(row, column, ref allAnimationCurveColumns); |
| | 0 | 773 | | } |
| | | 774 | | |
| | | 775 | | public UnityEngine.Object GetObject(int row, int column) |
| | 0 | 776 | | { |
| | 0 | 777 | | return GetCell(row, column, ref allObjectRefColumns); |
| | 0 | 778 | | } |
| | | 779 | | |
| | | 780 | | // Get ref |
| | | 781 | | |
| | | 782 | | public ref string GetStringRef(int row, int columnID) |
| | 0 | 783 | | { |
| | 0 | 784 | | return ref GetCellRef(row, columnID, ref allStringColumns); |
| | 0 | 785 | | } |
| | | 786 | | |
| | | 787 | | public ref bool GetBoolRef(int row, int columnID) |
| | 0 | 788 | | { |
| | 0 | 789 | | return ref GetCellRef(row, columnID, ref allBoolColumns); |
| | 0 | 790 | | } |
| | | 791 | | |
| | | 792 | | public ref char GetCharRef(int row, int columnID) |
| | 0 | 793 | | { |
| | 0 | 794 | | return ref GetCellRef(row, columnID, ref allCharColumns); |
| | 0 | 795 | | } |
| | | 796 | | |
| | | 797 | | public ref sbyte GetSbyteRef(int row, int columnID) |
| | 0 | 798 | | { |
| | 0 | 799 | | return ref GetCellRef(row, columnID, ref allSbyteColumns); |
| | 0 | 800 | | } |
| | | 801 | | |
| | | 802 | | public ref byte GetByteRef(int row, int columnID) |
| | 0 | 803 | | { |
| | 0 | 804 | | return ref GetCellRef(row, columnID, ref allByteColumns); |
| | 0 | 805 | | } |
| | | 806 | | |
| | | 807 | | public ref short GetShortRef(int row, int columnID) |
| | 0 | 808 | | { |
| | 0 | 809 | | return ref GetCellRef(row, columnID, ref allShortColumns); |
| | 0 | 810 | | } |
| | | 811 | | |
| | | 812 | | public ref ushort GetUshortRef(int row, int columnID) |
| | 0 | 813 | | { |
| | 0 | 814 | | return ref GetCellRef(row, columnID, ref allUshortColumns); |
| | 0 | 815 | | } |
| | | 816 | | |
| | | 817 | | public ref int GetIntRef(int row, int columnID) |
| | 0 | 818 | | { |
| | 0 | 819 | | return ref GetCellRef(row, columnID, ref allIntColumns); |
| | 0 | 820 | | } |
| | | 821 | | |
| | | 822 | | public ref uint GetUintRef(int row, int columnID) |
| | 0 | 823 | | { |
| | 0 | 824 | | return ref GetCellRef(row, columnID, ref allUintColumns); |
| | 0 | 825 | | } |
| | | 826 | | |
| | | 827 | | public ref long GetLongRef(int row, int columnID) |
| | 0 | 828 | | { |
| | 0 | 829 | | return ref GetCellRef(row, columnID, ref allLongColumns); |
| | 0 | 830 | | } |
| | | 831 | | |
| | | 832 | | public ref ulong GetUlongRef(int row, int columnID) |
| | 0 | 833 | | { |
| | 0 | 834 | | return ref GetCellRef(row, columnID, ref allUlongColumns); |
| | 0 | 835 | | } |
| | | 836 | | |
| | | 837 | | public ref float GetFloatRef(int row, int columnID) |
| | 0 | 838 | | { |
| | 0 | 839 | | return ref GetCellRef(row, columnID, ref allFloatColumns); |
| | 0 | 840 | | } |
| | | 841 | | |
| | | 842 | | public ref double GetDoubleRef(int row, int columnID) |
| | 0 | 843 | | { |
| | 0 | 844 | | return ref GetCellRef(row, columnID, ref allDoubleColumns); |
| | 0 | 845 | | } |
| | | 846 | | |
| | | 847 | | public ref Vector2 GetVector2Ref(int row, int columnID) |
| | 0 | 848 | | { |
| | 0 | 849 | | return ref GetCellRef(row, columnID, ref allVector2Columns); |
| | 0 | 850 | | } |
| | | 851 | | |
| | | 852 | | public ref Vector3 GetVector3Ref(int row, int columnID) |
| | 0 | 853 | | { |
| | 0 | 854 | | return ref GetCellRef(row, columnID, ref allVector3Columns); |
| | 0 | 855 | | } |
| | | 856 | | |
| | | 857 | | public ref Vector4 GetVector4Ref(int row, int columnID) |
| | 0 | 858 | | { |
| | 0 | 859 | | return ref GetCellRef(row, columnID, ref allVector4Columns); |
| | 0 | 860 | | } |
| | | 861 | | |
| | | 862 | | public ref Vector2Int GetVector2IntRef(int row, int columnID) |
| | 0 | 863 | | { |
| | 0 | 864 | | return ref GetCellRef(row, columnID, ref allVector2IntColumns); |
| | 0 | 865 | | } |
| | | 866 | | |
| | | 867 | | public ref Vector3Int GetVector3IntRef(int row, int columnID) |
| | 0 | 868 | | { |
| | 0 | 869 | | return ref GetCellRef(row, columnID, ref allVector3IntColumns); |
| | 0 | 870 | | } |
| | | 871 | | |
| | | 872 | | public ref Quaternion GetQuaternionRef(int row, int columnID) |
| | 0 | 873 | | { |
| | 0 | 874 | | return ref GetCellRef(row, columnID, ref allQuaternionColumns); |
| | 0 | 875 | | } |
| | | 876 | | |
| | | 877 | | public ref Rect GetRectRef(int row, int columnID) |
| | 0 | 878 | | { |
| | 0 | 879 | | return ref GetCellRef(row, columnID, ref allRectColumns); |
| | 0 | 880 | | } |
| | | 881 | | |
| | | 882 | | public ref RectInt GetRectIntRef(int row, int columnID) |
| | 0 | 883 | | { |
| | 0 | 884 | | return ref GetCellRef(row, columnID, ref allRectIntColumns); |
| | 0 | 885 | | } |
| | | 886 | | |
| | | 887 | | public ref Color GetColorRef(int row, int columnID) |
| | 0 | 888 | | { |
| | 0 | 889 | | return ref GetCellRef(row, columnID, ref allColorColumns); |
| | 0 | 890 | | } |
| | | 891 | | |
| | | 892 | | public ref LayerMask GetLayerMaskRef(int row, int columnID) |
| | 0 | 893 | | { |
| | 0 | 894 | | return ref GetCellRef(row, columnID, ref allLayerMaskColumns); |
| | 0 | 895 | | } |
| | | 896 | | |
| | | 897 | | public ref Bounds GetBoundsRef(int row, int columnID) |
| | 0 | 898 | | { |
| | 0 | 899 | | return ref GetCellRef(row, columnID, ref allBoundsColumns); |
| | 0 | 900 | | } |
| | | 901 | | |
| | | 902 | | public ref BoundsInt GetBoundsIntRef(int row, int columnID) |
| | 0 | 903 | | { |
| | 0 | 904 | | return ref GetCellRef(row, columnID, ref allBoundsIntColumns); |
| | 0 | 905 | | } |
| | | 906 | | |
| | | 907 | | public ref Hash128 GetHash128Ref(int row, int columnID) |
| | 0 | 908 | | { |
| | 0 | 909 | | return ref GetCellRef(row, columnID, ref allHash128Columns); |
| | 0 | 910 | | } |
| | | 911 | | |
| | | 912 | | public ref Gradient GetGradientRef(int row, int columnID) |
| | 0 | 913 | | { |
| | 0 | 914 | | return ref GetCellRef(row, columnID, ref allGradientColumns); |
| | 0 | 915 | | } |
| | | 916 | | |
| | | 917 | | public ref AnimationCurve GetAnimationCurveRef(int row, int columnID) |
| | 0 | 918 | | { |
| | 0 | 919 | | return ref GetCellRef(row, columnID, ref allAnimationCurveColumns); |
| | 0 | 920 | | } |
| | | 921 | | |
| | | 922 | | public ref UnityEngine.Object GetObjectRef(int row, int columnID) |
| | 0 | 923 | | { |
| | 0 | 924 | | return ref GetCellRef(row, columnID, ref allObjectRefColumns); |
| | 0 | 925 | | } |
| | | 926 | | |
| | | 927 | | // Get Column |
| | | 928 | | |
| | | 929 | | public string[] GetStringColumn(int columnID) |
| | 0 | 930 | | { |
| | 0 | 931 | | return GetColumn(columnID, ref allStringColumns); |
| | 0 | 932 | | } |
| | | 933 | | |
| | | 934 | | public bool[] GetBoolColumn(int columnID) |
| | 0 | 935 | | { |
| | 0 | 936 | | return GetColumn(columnID, ref allBoolColumns); |
| | 0 | 937 | | } |
| | | 938 | | |
| | | 939 | | public char[] GetCharColumn(int columnID) |
| | 0 | 940 | | { |
| | 0 | 941 | | return GetColumn(columnID, ref allCharColumns); |
| | 0 | 942 | | } |
| | | 943 | | |
| | | 944 | | public sbyte[] GetSbyteColumn(int columnID) |
| | 0 | 945 | | { |
| | 0 | 946 | | return GetColumn(columnID, ref allSbyteColumns); |
| | 0 | 947 | | } |
| | | 948 | | |
| | | 949 | | public byte[] GetByteColumn(int columnID) |
| | 0 | 950 | | { |
| | 0 | 951 | | return GetColumn(columnID, ref allByteColumns); |
| | 0 | 952 | | } |
| | | 953 | | |
| | | 954 | | public short[] GetShortColumn(int columnID) |
| | 0 | 955 | | { |
| | 0 | 956 | | return GetColumn(columnID, ref allShortColumns); |
| | 0 | 957 | | } |
| | | 958 | | |
| | | 959 | | public ushort[] GetUshortColumn(int columnID) |
| | 0 | 960 | | { |
| | 0 | 961 | | return GetColumn(columnID, ref allUshortColumns); |
| | 0 | 962 | | } |
| | | 963 | | |
| | | 964 | | public int[] GetIntColumn(int columnID) |
| | 0 | 965 | | { |
| | 0 | 966 | | return GetColumn(columnID, ref allIntColumns); |
| | 0 | 967 | | } |
| | | 968 | | |
| | | 969 | | public uint[] GetUintColumn(int columnID) |
| | 0 | 970 | | { |
| | 0 | 971 | | return GetColumn(columnID, ref allUintColumns); |
| | 0 | 972 | | } |
| | | 973 | | |
| | | 974 | | public long[] GetLongColumn(int columnID) |
| | 0 | 975 | | { |
| | 0 | 976 | | return GetColumn(columnID, ref allLongColumns); |
| | 0 | 977 | | } |
| | | 978 | | |
| | | 979 | | public ulong[] GetUlongColumn(int columnID) |
| | 0 | 980 | | { |
| | 0 | 981 | | return GetColumn(columnID, ref allUlongColumns); |
| | 0 | 982 | | } |
| | | 983 | | |
| | | 984 | | public float[] GetFloatColumn(int columnID) |
| | 0 | 985 | | { |
| | 0 | 986 | | return GetColumn(columnID, ref allFloatColumns); |
| | 0 | 987 | | } |
| | | 988 | | |
| | | 989 | | public double[] GetDoubleColumn(int columnID) |
| | 0 | 990 | | { |
| | 0 | 991 | | return GetColumn(columnID, ref allDoubleColumns); |
| | 0 | 992 | | } |
| | | 993 | | |
| | | 994 | | public Vector2[] GetVector2Column(int columnID) |
| | 0 | 995 | | { |
| | 0 | 996 | | return GetColumn(columnID, ref allVector2Columns); |
| | 0 | 997 | | } |
| | | 998 | | |
| | | 999 | | public Vector3[] GetVector3Column(int columnID) |
| | 0 | 1000 | | { |
| | 0 | 1001 | | return GetColumn(columnID, ref allVector3Columns); |
| | 0 | 1002 | | } |
| | | 1003 | | |
| | | 1004 | | public Vector4[] GetVector4Column(int columnID) |
| | 0 | 1005 | | { |
| | 0 | 1006 | | return GetColumn(columnID, ref allVector4Columns); |
| | 0 | 1007 | | } |
| | | 1008 | | |
| | | 1009 | | public Vector2Int[] GetVector2IntColumn(int columnID) |
| | 0 | 1010 | | { |
| | 0 | 1011 | | return GetColumn(columnID, ref allVector2IntColumns); |
| | 0 | 1012 | | } |
| | | 1013 | | |
| | | 1014 | | public Vector3Int[] GetVector3IntColumn(int columnID) |
| | 0 | 1015 | | { |
| | 0 | 1016 | | return GetColumn(columnID, ref allVector3IntColumns); |
| | 0 | 1017 | | } |
| | | 1018 | | |
| | | 1019 | | public Quaternion[] GetQuaternionColumn(int columnID) |
| | 0 | 1020 | | { |
| | 0 | 1021 | | return GetColumn(columnID, ref allQuaternionColumns); |
| | 0 | 1022 | | } |
| | | 1023 | | |
| | | 1024 | | public Rect[] GetRectColumn(int columnID) |
| | 0 | 1025 | | { |
| | 0 | 1026 | | return GetColumn(columnID, ref allRectColumns); |
| | 0 | 1027 | | } |
| | | 1028 | | |
| | | 1029 | | public RectInt[] GetRectIntColumn(int columnID) |
| | 0 | 1030 | | { |
| | 0 | 1031 | | return GetColumn(columnID, ref allRectIntColumns); |
| | 0 | 1032 | | } |
| | | 1033 | | |
| | | 1034 | | public Color[] GetColorColumn(int columnID) |
| | 0 | 1035 | | { |
| | 0 | 1036 | | return GetColumn(columnID, ref allColorColumns); |
| | 0 | 1037 | | } |
| | | 1038 | | |
| | | 1039 | | public LayerMask[] GetLayerMaskColumn(int columnID) |
| | 0 | 1040 | | { |
| | 0 | 1041 | | return GetColumn(columnID, ref allLayerMaskColumns); |
| | 0 | 1042 | | } |
| | | 1043 | | |
| | | 1044 | | public Bounds[] GetBoundsColumn(int columnID) |
| | 0 | 1045 | | { |
| | 0 | 1046 | | return GetColumn(columnID, ref allBoundsColumns); |
| | 0 | 1047 | | } |
| | | 1048 | | |
| | | 1049 | | public BoundsInt[] GetBoundsIntColumn(int columnID) |
| | 0 | 1050 | | { |
| | 0 | 1051 | | return GetColumn(columnID, ref allBoundsIntColumns); |
| | 0 | 1052 | | } |
| | | 1053 | | |
| | | 1054 | | public Hash128[] GetHash128Column(int columnID) |
| | 0 | 1055 | | { |
| | 0 | 1056 | | return GetColumn(columnID, ref allHash128Columns); |
| | 0 | 1057 | | } |
| | | 1058 | | |
| | | 1059 | | public Gradient[] GetGradientColumn(int columnID) |
| | 0 | 1060 | | { |
| | 0 | 1061 | | return GetColumn(columnID, ref allGradientColumns); |
| | 0 | 1062 | | } |
| | | 1063 | | |
| | | 1064 | | public AnimationCurve[] GetAnimationCurveColumn(int columnID) |
| | 0 | 1065 | | { |
| | 0 | 1066 | | return GetColumn(columnID, ref allAnimationCurveColumns); |
| | 0 | 1067 | | } |
| | | 1068 | | |
| | | 1069 | | public UnityEngine.Object[] GetObjectColumn(int columnID) |
| | 0 | 1070 | | { |
| | 0 | 1071 | | return GetColumn(columnID, ref allObjectRefColumns); |
| | 0 | 1072 | | } |
| | | 1073 | | |
| | | 1074 | | // Internal |
| | | 1075 | | |
| | | 1076 | | internal int AddColumnInternal<T>(string columnName, ref ArrayHolder<T>[] allColumnsOfType, Serializable.Seriali |
| | 0 | 1077 | | { |
| | 0 | 1078 | | int columnCount = allColumnsOfType?.Length ?? 0; |
| | 0 | 1079 | | Array.Resize(ref allColumnsOfType, columnCount + 1); |
| | 0 | 1080 | | allColumnsOfType[columnCount].TArray = new T[rowCount]; |
| | | 1081 | | |
| | 0 | 1082 | | string[] columnNamesForType = allColumnNames[(int)typeIndex].TArray; |
| | 0 | 1083 | | int columnNamesCount = columnNamesForType?.Length ?? 0; |
| | 0 | 1084 | | Array.Resize(ref columnNamesForType, columnNamesCount + 1); |
| | 0 | 1085 | | columnNamesForType[columnNamesCount] = columnName; |
| | 0 | 1086 | | allColumnNames[(int)typeIndex].TArray = columnNamesForType; |
| | | 1087 | | |
| | 0 | 1088 | | int columnIndex = columnEntriesFreeListHead; |
| | 0 | 1089 | | int columnIDToDenseIndexMapLength = columnIDToDenseIndexMap?.Length ?? 0; |
| | 0 | 1090 | | if (columnIndex >= columnIDToDenseIndexMapLength) |
| | 0 | 1091 | | { |
| | 0 | 1092 | | int newSize = columnIndex * 2; |
| | 0 | 1093 | | newSize = newSize == 0 ? 1 : newSize; |
| | 0 | 1094 | | Array.Resize(ref columnIDToDenseIndexMap, newSize); |
| | 0 | 1095 | | for (int i = 0; i < columnIndex; i++) |
| | 0 | 1096 | | { |
| | 0 | 1097 | | ref ColumnEntry entry = ref columnIDToDenseIndexMap[columnIndex + i]; |
| | 0 | 1098 | | entry.columnDenseIndex = columnIndex + i + 1; |
| | 0 | 1099 | | entry.ColumnType = Serializable.SerializableTypes.Invalid; |
| | 0 | 1100 | | } |
| | 0 | 1101 | | } |
| | | 1102 | | |
| | 0 | 1103 | | ref int[] denseIndexToIDMap = ref columnDenseIndexToIDMap[(int)typeIndex].TArray; |
| | 0 | 1104 | | int denseIndexToIDMapLength = denseIndexToIDMap?.Length ?? 0; |
| | 0 | 1105 | | Array.Resize(ref denseIndexToIDMap, denseIndexToIDMapLength + 1); |
| | 0 | 1106 | | denseIndexToIDMap[denseIndexToIDMapLength] = columnIndex; |
| | | 1107 | | |
| | 0 | 1108 | | ref ColumnEntry newEntry = ref columnIDToDenseIndexMap[columnIndex]; |
| | 0 | 1109 | | newEntry.columnDenseIndex = denseIndexToIDMapLength; |
| | 0 | 1110 | | newEntry.ColumnType = typeIndex; |
| | | 1111 | | |
| | 0 | 1112 | | insertAt = insertAt < 0 ? combinedColumnCount : insertAt; |
| | 0 | 1113 | | ref int[] columnOrdersOfType = ref allColumnOrders[(int)typeIndex].TArray; |
| | 0 | 1114 | | int columnOrdersOfTypeLength = columnOrdersOfType?.Length ?? 0; |
| | 0 | 1115 | | Array.Resize(ref columnOrdersOfType, columnOrdersOfTypeLength + 1); |
| | 0 | 1116 | | columnOrdersOfType[columnOrdersOfTypeLength] = insertAt; |
| | | 1117 | | |
| | 0 | 1118 | | for (int i = 0; i < Serializable.SerializableTypesCount; i++) |
| | 0 | 1119 | | { |
| | 0 | 1120 | | int[] columnOrdersOfTypeCurrent = allColumnOrders[i].TArray; |
| | 0 | 1121 | | int columnOrdersLength = columnOrdersOfTypeCurrent?.Length ?? 0; |
| | 0 | 1122 | | for (int j = 0; j < columnOrdersLength; j++) |
| | 0 | 1123 | | { |
| | 0 | 1124 | | int columnOrderCurrent = columnOrdersOfTypeCurrent[j]; |
| | | 1125 | | |
| | 0 | 1126 | | if (columnOrderCurrent > insertAt) |
| | 0 | 1127 | | { |
| | 0 | 1128 | | columnOrdersOfType[j] = columnOrderCurrent + 1; |
| | 0 | 1129 | | } |
| | 0 | 1130 | | } |
| | 0 | 1131 | | } |
| | | 1132 | | |
| | 0 | 1133 | | ++combinedColumnCount; |
| | 0 | 1134 | | dataVersion++; |
| | | 1135 | | |
| | 0 | 1136 | | return columnIndex; |
| | 0 | 1137 | | } |
| | | 1138 | | |
| | | 1139 | | internal void RemoveColumnInternal<T>(ref ArrayHolder<T>[] allColumnsOfType, Serializable.SerializableTypes type |
| | 0 | 1140 | | { |
| | 0 | 1141 | | int columnLocation = columnIDToDenseIndexMap[columnID].columnDenseIndex; |
| | | 1142 | | |
| | 0 | 1143 | | int lastIndex = allColumnsOfType.Length - 1; |
| | 0 | 1144 | | allColumnsOfType[columnLocation] = allColumnsOfType[lastIndex]; |
| | | 1145 | | // T[][] newColumnArray = new T[lastIndex][]; |
| | 0 | 1146 | | ArrayHolder<T>[] newColumnArray = new ArrayHolder<T>[lastIndex]; |
| | 0 | 1147 | | Array.Copy(allColumnsOfType, 0, newColumnArray, 0, lastIndex); |
| | 0 | 1148 | | allColumnsOfType = newColumnArray; |
| | | 1149 | | |
| | 0 | 1150 | | string[] columnNamesOfType = allColumnNames[(int)typeIndex].TArray; |
| | 0 | 1151 | | columnNamesOfType[columnLocation] = columnNamesOfType[lastIndex]; |
| | 0 | 1152 | | string[] newColumnNamesOfType = new string[lastIndex]; |
| | 0 | 1153 | | Array.Copy(columnNamesOfType, 0, newColumnNamesOfType, 0, lastIndex); |
| | 0 | 1154 | | allColumnNames[(int)typeIndex].TArray = newColumnNamesOfType; |
| | | 1155 | | |
| | 0 | 1156 | | int[] columnOrdersOfType = allColumnOrders[(int)typeIndex].TArray; |
| | 0 | 1157 | | int columnOrder = columnOrdersOfType[columnLocation]; |
| | 0 | 1158 | | columnOrdersOfType[columnLocation] = columnOrdersOfType[lastIndex]; |
| | 0 | 1159 | | int[] newColumnOrdersOfType = new int[lastIndex]; |
| | 0 | 1160 | | Array.Copy(columnOrdersOfType, 0, newColumnOrdersOfType, 0, lastIndex); |
| | 0 | 1161 | | allColumnOrders[(int)typeIndex].TArray = newColumnOrdersOfType; |
| | | 1162 | | |
| | 0 | 1163 | | int[] denseIndicesOfType = columnDenseIndexToIDMap[(int)typeIndex].TArray; |
| | 0 | 1164 | | int sparseIndexAt = denseIndicesOfType[columnLocation]; |
| | 0 | 1165 | | int sparseIndexToSwap = columnOrdersOfType[lastIndex]; |
| | 0 | 1166 | | ref ColumnEntry sparseIndexToFree = ref columnIDToDenseIndexMap[sparseIndexAt]; |
| | 0 | 1167 | | sparseIndexToFree.ColumnType = Serializable.SerializableTypes.Invalid; |
| | 0 | 1168 | | sparseIndexToFree.columnDenseIndex = columnEntriesFreeListHead; |
| | 0 | 1169 | | columnEntriesFreeListHead = sparseIndexAt; |
| | 0 | 1170 | | columnIDToDenseIndexMap[sparseIndexToSwap].columnDenseIndex = columnLocation; |
| | 0 | 1171 | | denseIndicesOfType[columnLocation] = sparseIndexToSwap; |
| | 0 | 1172 | | int[] newDenseIndicesOfType = new int[lastIndex]; |
| | 0 | 1173 | | Array.Copy(denseIndicesOfType, 0, newDenseIndicesOfType, 0, lastIndex); |
| | 0 | 1174 | | columnDenseIndexToIDMap[(int)typeIndex].TArray = newDenseIndicesOfType; |
| | | 1175 | | |
| | 0 | 1176 | | for (int i = 0; i < Serializable.SerializableTypesCount; i++) |
| | 0 | 1177 | | { |
| | 0 | 1178 | | int[] columnOrdersOfTypeCurrent = allColumnOrders[i].TArray; |
| | | 1179 | | |
| | 0 | 1180 | | int columnOrdersLength = columnOrdersOfTypeCurrent.Length; |
| | 0 | 1181 | | for (int j = 0; j < columnOrdersLength; j++) |
| | 0 | 1182 | | { |
| | 0 | 1183 | | int columnOrderCurrent = columnOrdersOfTypeCurrent[j]; |
| | | 1184 | | |
| | 0 | 1185 | | if (columnOrderCurrent > columnOrder) |
| | 0 | 1186 | | { |
| | 0 | 1187 | | columnOrdersOfType[j] = columnOrderCurrent - 1; |
| | 0 | 1188 | | } |
| | 0 | 1189 | | } |
| | 0 | 1190 | | } |
| | | 1191 | | |
| | 0 | 1192 | | --combinedColumnCount; |
| | 0 | 1193 | | dataVersion++; |
| | 0 | 1194 | | } |
| | | 1195 | | |
| | | 1196 | | internal void InsertRowsOfTypeInternal<T>(ref ArrayHolder<T>[] allColumnsOfType, int insertAt, int numberOfNewRo |
| | 0 | 1197 | | { |
| | 0 | 1198 | | int columnCount = allColumnsOfType?.Length ?? 0; |
| | 0 | 1199 | | for (int i = 0; i < columnCount; i++) |
| | 0 | 1200 | | { |
| | 0 | 1201 | | ref T[] column = ref allColumnsOfType[i].TArray; |
| | 0 | 1202 | | int newRowCount = rowCount + numberOfNewRows; |
| | 0 | 1203 | | Array.Resize(ref column, newRowCount); |
| | 0 | 1204 | | for (int j = newRowCount - 1; j > insertAt + numberOfNewRows - 1; j--) |
| | 0 | 1205 | | { |
| | 0 | 1206 | | column[j] = column[j - numberOfNewRows]; |
| | 0 | 1207 | | } |
| | | 1208 | | |
| | 0 | 1209 | | for (int j = 0; j < numberOfNewRows; j++) |
| | 0 | 1210 | | { |
| | 0 | 1211 | | column[insertAt + i] = default; |
| | 0 | 1212 | | } |
| | 0 | 1213 | | } |
| | 0 | 1214 | | } |
| | | 1215 | | |
| | | 1216 | | internal void DeleteRowsOfTypeInternal<T>(ref ArrayHolder<T>[] allColumnsOfType, int removeAt, int numberOfRowsT |
| | 0 | 1217 | | { |
| | 0 | 1218 | | int columnCount = allColumnsOfType?.Length ?? 0; |
| | | 1219 | | |
| | 0 | 1220 | | for (int i = 0; i < columnCount; i++) |
| | 0 | 1221 | | { |
| | 0 | 1222 | | ref T[] column = ref allColumnsOfType[i].TArray; |
| | 0 | 1223 | | int newRowCount = rowCount - numberOfRowsToDelete; |
| | | 1224 | | |
| | 0 | 1225 | | for (int j = removeAt; j < rowCount - numberOfRowsToDelete; j++) |
| | 0 | 1226 | | { |
| | 0 | 1227 | | column[j] = column[j + numberOfRowsToDelete]; |
| | 0 | 1228 | | } |
| | | 1229 | | |
| | 0 | 1230 | | Array.Resize(ref column, newRowCount); |
| | 0 | 1231 | | } |
| | 0 | 1232 | | } |
| | | 1233 | | |
| | | 1234 | | internal ref T GetCellRef<T>(int row, int columnID, ref ArrayHolder<T>[] allColumnsOfType) |
| | 0 | 1235 | | { |
| | 0 | 1236 | | int column = columnIDToDenseIndexMap[columnID].columnDenseIndex; |
| | 0 | 1237 | | return ref allColumnsOfType[column][row]; |
| | 0 | 1238 | | } |
| | | 1239 | | |
| | | 1240 | | internal T GetCell<T>(int row, int columnID, ref ArrayHolder<T>[] allColumnsOfType) |
| | 0 | 1241 | | { |
| | 0 | 1242 | | int column = columnIDToDenseIndexMap[columnID].columnDenseIndex; |
| | 0 | 1243 | | return allColumnsOfType[column][row]; |
| | 0 | 1244 | | } |
| | | 1245 | | |
| | | 1246 | | internal ulong SetCell<T>(int row, int columnID, ref ArrayHolder<T>[] allColumnsOfType, T value) |
| | 0 | 1247 | | { |
| | 0 | 1248 | | int column = columnIDToDenseIndexMap[columnID].columnDenseIndex; |
| | 0 | 1249 | | allColumnsOfType[column][row] = value; |
| | 0 | 1250 | | dataVersion++; |
| | 0 | 1251 | | return dataVersion; |
| | 0 | 1252 | | } |
| | | 1253 | | |
| | | 1254 | | internal T[] GetColumn<T>(int columnID, ref ArrayHolder<T>[] allColumnsOfType) |
| | 0 | 1255 | | { |
| | 0 | 1256 | | int column = columnIDToDenseIndexMap[columnID].columnDenseIndex; |
| | 0 | 1257 | | return allColumnsOfType[column].TArray; |
| | 0 | 1258 | | } |
| | | 1259 | | } |
| | | 1260 | | } |